package components.powerups;

import java.awt.Color;

import scenes.CollisionablesScene;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.appearances.Appearance;
import com.uqbar.vainilla.appearances.Circle;
import components.CollisionableComponent;

public abstract class PowerUp extends CollisionableComponent<CollisionablesScene> {

	private int speed;
	
	public PowerUp(Appearance ap, double x, double y) {
		super(20, 20, x, y);
		this.speed = 100;
		this.setAppearance(ap);
	}
	public PowerUp(Appearance ap) {
		this(ap, 0, 0);
	}

	@Override
	protected void defineCollide(CollisionableComponent gc) {
		gc.collideWithPowerUp(this);
	}

	@Override
	protected void effectiveUpdate(DeltaState deltaState) {
		double intensity = deltaState.getDelta() * this.speed;
		double nx, ny;
		
		nx = this.getX();
		ny = this.getY() +intensity;
		
		if (! this.collide(nx, ny)){
			this.updateCoords(0, intensity);
		}
	}

	@Override
	public boolean isSolid() {
		return false;
	}

	@Override
	protected void onCollisionWithSolid(CollisionableComponent gc) {
	}

	public abstract void doEffect(PowerUpResolver resolver);

}
